var cam = void 0,scene = void 0,renderer = void 0,
clock = void 0,smokeMaterial = void 0,
h = void 0,w = void 0,
smokeParticles = [];

var animate = function animate() {
    var delta = clock.getDelta();

    requestAnimationFrame(animate);

    [].forEach.call(smokeParticles, function (sp) {
        sp.rotation.z += delta * 0.2;
    });

    renderer.render(scene, cam);
},
resize = function resize() {
    renderer.setSize(window.innerWidth, window.innerHeight);

},
lights = function lights() {
    var light = new THREE.DirectionalLight(0xffffff, 0.5);

    clock = new THREE.Clock();

    renderer = new THREE.WebGLRenderer();
    renderer.setClearColor(0x00547f, 1);
    renderer.setSize(w, h);

    scene = new THREE.Scene();

    light.position.set(-1, 0, 1);
    scene.add(light);
},
camera = function camera() {
    cam = new THREE.PerspectiveCamera(
    75,
    w / h,
    1,
    10000);


    cam.position.z = 1000;

    scene.add(cam);
},
action = function action() {
    var loader = new THREE.TextureLoader();

    loader.crossOrigin = '';

    loader.load(
    'blue-smoke.png',
    function onLoad(texture) {
        var smokeGeo = new THREE.PlaneBufferGeometry(300, 300);

        smokeMaterial = new THREE.MeshLambertMaterial({
            map: texture,
            transparent: true });


        for (var p = 0, l = 350; p < l; p++) {
            var particle = new THREE.Mesh(smokeGeo, smokeMaterial);

            particle.position.set(
            Math.random() * 500 - 250,
            Math.random() * 500 - 250,
            Math.random() * 1000 - 100);


            particle.rotation.z = Math.random() * 360;
            scene.add(particle);
            smokeParticles.push(particle);
        }

        animate();
    });


},
init = function init() {
    h = window.innerHeight;
    w = window.innerWidth;

    lights(); //💡
    camera(); // 🎥
    action(); // 🎬

    document.body.appendChild(renderer.domElement);
    window.addEventListener('resize', resize);
};

init();